#!/bin/bash
# Build script for x86_64-unknown-linux-musl target
# This script handles the compilation issues caused by global cargo config

set -e

echo "Building moparse for x86_64-unknown-linux-musl target..."

# Use rustup-managed cargo and rustc, and override rustflags to avoid conflicts
# with global cargo config that uses zig linker
RUSTC=~/.cargo/bin/rustc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=+crt-static" \
~/.cargo/bin/cargo build --target x86_64-unknown-linux-musl --release

echo ""
echo "Build completed successfully!"
echo "Binary location: target/x86_64-unknown-linux-musl/release/mo"
echo ""

# Display binary information
ls -lh target/x86_64-unknown-linux-musl/release/mo
file target/x86_64-unknown-linux-musl/release/mo
